<?php
session_start();
/*ini_set("display_errors","1");
error_reporting(E_ALL);*/
include ("config.php");
require_once 'JSON.php';
?>
<link href="<?php echo ESTILO?>/bykom.css" rel="stylesheet" type="text/css">
<?php
   require_once(ROOT_DIR_CLASES.'/PHPLogger.php');
   $LOGGER = new PHPLogger(LOGGER_PATH, LOGGER_LEVEL);
   require_once(ROOT_DIR_CLASES.'/cCliente.php');
   $loginClass = new CLogin();
   $loginClass->codigorc = $_POST['codigorc'];
   $loginClass->codigocuenta = $_POST['codigocuenta'];
   $loginClass->particion = $_POST['particion'];
   $loginClass->password = $_POST['password'];
   $loginClass->objetivo = $_POST['objetivo'];
   $loginClass->codigoFlota = $_POST['codigoFlota'];
   $loginClass->alias = $_POST['aliasString'];
   $loginClass->codigoDealer = $_POST['codigoDealer'];

   $loginClass = BykomCliente::LoginInitialValidation($loginClass);

   /*$fecha=mktime(0,0,0,1,1,2010);
   setcookie('wcObjetivo',$loginClass->objetivo,$fecha,'','',0);*/
   if (!isset($_SESSION['cliente'])) {
	   	if ($loginClass->errorCode == 0) {

	        $_SESSION['cliente'] = session_id();
			$_SESSION['isWebCliente'] = 1; //indicamos que entramos a traves de "Web-Cliente"
	        $_SESSION['ultfecha'] = $loginClass->ultimaFecha;
	        $_SESSION['objetivo'] = $loginClass->objetivoDB;
	        $_SESSION['objetivoReal'] = $loginClass->objetivo;
			$_SESSION['uniqueID']= $loginClass->cuentaFk;
			$_SESSION['tablaID'] = $loginClass->tablaId;
			$_SESSION['monitoreoWeb']= $loginClass->monitoreoWeb;
			$_SESSION['labelLogin']= $loginClass->getLabelLogin();
			$_SESSION['usuariosLogueados'] = $loginClass->usuariosLogueados;

			$_SESSION['loginClass'] = serialize($loginClass);
	   	} else {
	   		echo("<script language='JavaScript' type='text/javascript'>");
			echo("location.href='welcome.php?error=" . $loginClass->errorCode . "'");
			echo("</script>");
	        die;
	   	}
   } else {
   		exit('Ya ha iniciado sesion con este navegador. Intente loguearse con otro (2).');
   }

?>